package persistencia;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import negocio.Sede;
import controlador.Sistema;

public class perSede {
	private Sistema sist;
	private Sede s;
	public void levantarMemoriaSedes()
	{
		
		try {
			sist=Sistema.getInstance();
			//lazy load
			Connection con=PoolConnection.getPoolConnection().getConnection();		
			PreparedStatement ps=con.prepareStatement("Select IDSEDE,NOMBRE from SEDE");
			ResultSet rs=ps.executeQuery();
			while(rs.next())
			{
				s=new Sede();
				s.setNroSede(rs.getInt(1));
				s.setNombre(rs.getString(2));
				sist.altaSede(s);
			}
			PoolConnection.getPoolConnection().releaseConnection(con);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	}
}
